/*
 * Copyright 2012 dev.takayuki@gmail.com All Rights Reserved.
 */

package dev.takayuki.android.calculator.core;

public final class Param {

	static final int TYPE_NUMBER	= 0;
	static final int TYPE_ADD		= 1;
	static final int TYPE_SUB		= 2;
	static final int TYPE_MUL		= 3;
	static final int TYPE_DIV		= 4;
	static final int TYPE_SIN		= 5;
	static final int TYPE_COS		= 6;
	static final int TYPE_TAN		= 7;

	public static final Param ADD	= new Param(TYPE_ADD);
	public static final Param SUB	= new Param(TYPE_SUB);
	public static final Param MUL	= new Param(TYPE_MUL);
	public static final Param DIV	= new Param(TYPE_DIV);
	public static final Param SIN	= new Param(TYPE_SIN);
	public static final Param COS	= new Param(TYPE_COS);
	public static final Param TAN	= new Param(TYPE_TAN);

	private int iType;
	private double iDouble;

	public Param(double number) {
		iType = TYPE_NUMBER;
		iDouble = number;
	}

	private Param(int type) {
		switch (type) {
		case TYPE_ADD:
		case TYPE_SUB:
		case TYPE_MUL:
		case TYPE_DIV:
		case TYPE_SIN:
		case TYPE_COS:
		case TYPE_TAN:
			break;
		case TYPE_NUMBER:
		default:
			throw new Error();
		}

		iType = type;
	}

	int getType() {
		return iType;
	}

	double getValue() {
		if (TYPE_NUMBER != iType) {
			throw new IllegalStateException();
		}

		return iDouble;
	}
	
}